home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc51bugs.zip / Q34409 < prev    next >
Text File  |  1988-08-19  |  2KB  |  70 lines

  1. Q34409 Incorrect C2129 Error Generated for Static Function
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.  
  8. The compiler incorrectly generates the error "C2129: static function
  9. `identifier' not found" under the following circumstances:
  10.  
  11.    1. The function has "static" visibility.
  12.    2. The function is defined after the functions that call it.
  13.    3. There are two functions calling it, or there only is one
  14.       function calling it, but the /Za option is being used.
  15.    4. The functions calling it declare it with function prototypes
  16.       locally (i.e., inside the function rather than outside of it).
  17.  
  18. Microsoft has confirmed this to be a problem in Version 5.10. We
  19. are researching this problem and will post new information as
  20. it becomes available.
  21.  
  22. To work around the problem, change one of the requirements listed above
  23. (i.e.,  remove the "static" keyword, or define the function before it
  24. is used, or move the function prototypes outside of any function).
  25.  
  26. More Information:
  27.  
  28.  
  29. The sample program below demonstrates a problem in C Version 5.10. The
  30. compiler generates a C2129 error on the second call to y(); it seems
  31. to "forget" that y is defined later in the file.
  32.  
  33. This problem will not occur if any of the following are true:
  34.  
  35. 1. The y() function is not given the "static" attribute.
  36. 2. The test() function does not call y() and /Ze is used.
  37. 3. The function prototypes for y() are moved out from inside the
  38.    functions test() and x().
  39.  
  40. To work around the problem, compile with /W3 to see C4074 warnings.
  41. Compile with /Ze; then with /Za to see the difference in C2129 errors.
  42.  
  43. The following program demonstrates the problem:
  44.  
  45. #include <stdio.h>
  46.  
  47. void test(void);
  48. void test (void)
  49. {
  50.   static void y (char c);     /* C4074 warning if /W3 /Ze used */
  51.   char c = 't';
  52.   y (c) ;                     /* C2129 error on this line */
  53. }
  54.  
  55. void x (void);
  56. void x (void)
  57. {
  58.   static void y (char c);     /* C4074 warning if /W3 /Ze used */
  59.   char c = 'x';
  60.   y (c);                      /* C2129 error on this line if /Za used */
  61. }
  62.  
  63. static void y (char c)
  64. {
  65.   printf ("%c\n", c);
  66. }
  67.  
  68. Keywords:  buglist5.10
  69. Updated  88/08/19 07:41
  70.